package com.woniuxy.controller;


import com.woniuxy.client.OrderServiceFeignClient;
import com.woniuxy.entity.Department;
import com.woniuxy.entity.Doctor;
import com.woniuxy.entity.ShopOrders;
import com.woniuxy.service.departmentService;
import com.woniuxy.utils.ResponseResult;
import com.woniuxy.vo.schedulesDoc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/medical")
public class departmentController {

    @Autowired
    departmentService departmentservice;

    @Autowired
    OrderServiceFeignClient orderServiceFeignClient;
    // 获取所有的科室
    @GetMapping("/findAll")  // medical/findAll
    public ResponseResult<List<Department>> findAll(){
        List<Department> Departments = departmentservice.findAll();
        System.out.println(".................."+Departments);
        return ResponseResult.success(Departments);
    }
    //根据科室id 获取 医生的信息
    @PostMapping("/getDoctorsByDepartID")   // medical/getDoctorsByDepartID
    public ResponseResult<List<Doctor>> getDoctorsByDepartID(@RequestBody Department department){
        return ResponseResult.success( departmentservice.getDoctorsByDepartID(department));
    }

   // 查看单个医生的所有排班余量
   @PostMapping("/getSchedules")
   public ResponseResult<List<schedulesDoc>> getSchedules(@RequestBody Map<String, Integer> request) {
       return ResponseResult.success(departmentservice.getSchedules(request.get("doctorId")));
   }
   //生成订单信息
   @PostMapping("/insert")
   public ResponseResult<String> insertOrderMedical(@RequestBody ShopOrders shopOrders) {
       orderServiceFeignClient.insertOrderMedical(shopOrders);
       return ResponseResult.success();
   }
}
